// .txt

beginzonescript;

variables;

short im_hostile = 0;
short last_abil;
short counter = 0;
short set_ter1 = 0;
short did_alert = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();

	add_ability(4020,10,57,0);
	add_ability(4021,10,57,0);

	set_name(4023,"Misttalker Ilia");
	set_boss_level(4023,1);
	set_name(4024,"Old One-Eye");
	set_boss_level(4024,1);
	set_name(4025,"Gorm the Hack");
	set_boss_level(4025,1);

	if (difficulty() > 1) {
		set_percent_adjust(4023,6,-50);
		set_percent_adjust(4023,3,100);
		set_percent_adjust(4024,11,50);
		set_percent_adjust(4025,2,100);
		set_percent_adjust(4025,12,100);
		}
		
	set_attack_range(30005,5);

//	add_ability(short which_char_or_group,short which_slot,short which_ability,0);

//	if (is_town_clear(ME))
//		clean_up_town();

	if (gf(40,11) == 0)
		sf(40,5,0);
		else {
			erase_char(30001);
			erase_char(30003);
			erase_char(30004);
			erase_char(30005);
			
			if (gf(40,25) == 0)
				kill_object(31);
			}
	
	if (gf(40,13) > 0) {
		}
		else sf(40,14,0);
		
	sf(40,26,1);
	sf(40,27,0);
	if (gf(40,13) > 0) {
		sf(40,26,1);
		sf(40,27,1);
		}
	break;

beginstate EXIT_STATE;

break;

beginstate START_STATE;
	if ((gf(40,14) == 0) && (on_which_layer() == 1) && (party_within_dist(28,13,4))) {
		sf(40,14,1);
		sf(40,26,0);
		sf(40,27,1);
		
		spawn_creature(4030);
		set_name(4030,"Lost Misttalker");
		set_boss_level(4030,2);
		change_max_health(4030,100);
		set_percent_adjust(4030,0,75);
		
		activate_hidden_group(7);
		set_name(30007,"Shadow Drake");
		set_boss_level(30007,1);
		set_summon_level(30007,2);

		set_percent_adjust(4030,10,20);
		set_percent_adjust(30007,10,20);
		set_percent_adjust(4030,3,50);
		set_percent_adjust(30007,3,50);
		
		begin_talk_mode(14);
		}
	if ((gf(40,14) == 1) && (char_ok(4030) == FALSE)) {
		sf(40,14,2);
		sf(40,13,1);
		
		erase_char(30007);
		erase_char(30008);
		erase_char(30009);
		
		award_party_xp(100);
		
		begin_talk_mode(15);
		}
	//if ((set_ter1 == 0) && (gf(0,0) > 0)) {
	//	set_ter1 = 1;
	//	set_terrain(,,,);
	//	}
		
	// if (gf(,) == 0) {
	//if (get_ran(1,0,100) < 10)
	//	give_char_text_bubble(,"");
	//	}

	//if (gf(,) < 2) {
	//	inc_flag(,,1);
	//	if (gf(,) == 2)
	//		begin_talk_mode();
	//	}

	if (((is_combat()) && (tick_difference(last_abil,get_current_tick()) > 0)) || ((is_town()) && (tick_difference(last_abil,get_current_tick()) > 3))) {
		last_abil = get_current_tick();
		if (gf(40,14) == 1) {
			if (char_ok(4035) == FALSE)
				spawn_creature(4035);
			if (char_ok(4036) == FALSE)
				spawn_creature(4036);
			if (char_ok(4037) == FALSE)
				spawn_creature(4037);
			if (char_ok(4038) == FALSE)
				spawn_creature(4038);
			if (char_ok(4039) == FALSE)
				spawn_creature(4039);
			if (char_ok(4040) == FALSE)
				spawn_creature(4040);

			if (char_ok(4041) == FALSE)
				spawn_creature(4041);
			if (char_ok(4042) == FALSE)
				spawn_creature(4042);
			if (char_ok(4043) == FALSE)
				spawn_creature(4043);
			if (char_ok(4044) == FALSE)
				spawn_creature(4044);
			if (char_ok(4045) == FALSE)
				spawn_creature(4045);
			if (char_ok(4046) == FALSE)
				spawn_creature(4046);
			}
		}
break;

beginstate 10;
	if (did_alert == 0) {
		did_alert = 1;
		set_attitude(30001,10);
		}
break;

beginstate 11;
break;

beginstate 12;
break;

beginstate 13;
break;

//	print_str("");
//	set_terrain_string_range(".",1);
//	set_terrain_string_range("The sign says - .",1);
